/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package christieprogram;

import javax.swing.JOptionPane;

/**
 *
 * @author Alex
 */
public class CrapCode {
    //    public static void main(String[] arg) throws Exception {
//        file = new File[10];
//        num_files = 0;
//
//
//        try {
//            input = new BufferedReader(new InputStreamReader(System.in));
//
//
//
//            if (arg.length >= 1 && file_extension(arg[0], ".csv") != -1) {
//                if (file_extension(arg[0], ".csv") == 1) {
//                    arg[0] = arg[0] + ".csv";
//                }
//
//                file[0] = new File(arg[0]);
//
//                JOptionPane.showMessageDialog(null,"File #1: \"" + arg[0] + "\" has been opened successfully");
//                num_files++;
//            }
//
//
//
//            if (arg.length >= 2 && file_extension(arg[1], ".csv") != -1) {
//                if (file_extension(arg[1], ".csv") == 1) {
//                    arg[1] = arg[1] + ".csv";
//                }
//
//                file[1] = new File(arg[1]);
//
//                JOptionPane.showMessageDialog(null,"File #2: \"" + arg[1] + "\" has been opened successfully");
//                num_files++;
//            }
//
//
////
////            if (file[0] == null) {
////                String name1;
////
////                do {
////                    do {
////                        JOptionPane.showMessageDialog(null,"Please input the first CSV file's name:");
////                        name1 = input.readLine();
////                    } while (file_extension(name1, ".csv") == -1);
////
////                    if (file_extension(name1, ".csv") == 1) {
////                        name1 = name1 + ".csv";
////                    }
////                } while (!open_file(0, name1));
////
//
////                JOptionPane.showMessageDialog(null,"File #1: \"" + name1 + "\" has been opened successfully");
////                num_files++;
////            }
////
////        } catch (Exception e) {
////            JOptionPane.showMessageDialog(null,"There was an error:\n" + e);
////        }
//
//
//
//
////
//////	try
////        {
////            String command;
////
////            int status = 0;
////
////            do {
////                status_report(status);
////
////                command = input.readLine();
////
////                status = preform(command);
////            } while (status != -1);
////        }
//////	catch (Exception e)
////        {
//////		JOptionPane.showMessageDialog(null,"There was an error:\n"+e);
////        }
//
//    }

//    static void status_report(int status) {
//        switch (status) {
//            case -1:
//                JOptionPane.showMessageDialog(null,"Closing program.");
//                break;
//            case 0:
//                JOptionPane.showMessageDialog(null,"What would you like to do next?");
//                break;
//            case 1:
//                JOptionPane.showMessageDialog(null,"");
//                break;
//        }
//    }
    
//    public static int OpenFile() throws IOException {
//        {
//            String name;
//
//            do {
//                JOptionPane.showMessageDialog(null,"Please input the file's name:");
//
//                name = input.readLine();
//            } while (file_extension(name, ".csv") == -1);
//
//            if (file_extension(name, ".csv") == 1) {
//                name += ".csv";
//            }
//
//        AddFile(name);
//
//            return 0;
//        }
    // }
    //    public static int preform(String command) throws Exception {
//	try
//        {
//            if (command.charAt(0) == 'h') {
//                help_menu();
//                return 0;
//            }
//            if (command.charAt(0) == 'o') {
//                return OpenFile();
//            }
//            boolean format = false;
//            if (command.length() > 1 && command.substring(0, 2).compareTo("pm") == 0) {
//                format = true;
//                command = "m" + command.substring(2);
//            }
//            if (command.length() > 1 && command.substring(0, 2).compareTo("cf") == 0) {
//                String line = command.substring(2).replaceAll(" ", "");
//                if (is_int(line)) {
//                    compile_finances(Integer.parseInt(line) - 1);
//                } else {
//                    // get file number and format
//                }
//                return 0;
//            }
////            if (command.length() > 1 && command.substring(0, 2).compareTo("pn") == 0) {
////                String line = command.substring(2).replaceAll(" ", "");
////
////                if (is_int(line)) {
////                    format_file(Integer.parseInt(line) - 1, false);
////                } else {
////                    // get file number and format
////                }
////
////                return 0;
////            }
//            if (command.length() > 1 && command.substring(0, 2).compareTo("pi") == 0) {
//                String[] files = command.substring(2).replaceAll(" ", "").split(",");
//                JOptionPane.showMessageDialog(null,"Please spell out the column name that you would like to update.");
//                String column_name = input.readLine();
//                if (files.length > 1 && is_int(files[0]) && is_int(files[1])) {
//                    pull_info(Integer.parseInt(files[0]) - 1, Integer.parseInt(files[1]) - 1, column_name);
//                } else {
//                    // get file number and format
//                }
//                return 0;
//            }
//            if (command.charAt(0) == 'm') {
//                String[] files = command.substring(1).replaceAll(" ", "").split(",");
//                String in;
//                int file1 = -1, file2 = -1;
//                if (files.length > 2) {
//                    JOptionPane.showMessageDialog(null,"Too many inputs...\n");
//                    return 0;
//                }
//                if (!is_int(files[0]) || !is_int(files[1])) {
//                    return 0;
//                }
//                if (files.length == 1) {
//                    file1 = Integer.parseInt(files[0]);
//                }
//                if (files.length == 2) {
//                    file2 = Integer.parseInt(files[1]);
//                }
//                if (files.length == 0) {
//                    file_list();
//                    do {
//                        JOptionPane.showMessageDialog(null,"\nPlease pick the first file by number.");
//                        in = input.readLine();
//                        if (in.compareTo("o") == 0) {
//                            preform("o");
//                            file1 = num_files - 1;
//                            break;
//                        }
//                        if (in.compareTo("f") == 0) {
//                            preform("f");
//                        }
//                    } while (!is_int(in));
//                    file1 = Integer.parseInt(in);
//                }
//                if (files.length == 1 || files.length == 0) {
//                    file_list();
//                    JOptionPane.showMessageDialog(null,"\nPlease pick the second file by number.");
//                    do {
//                        in = input.readLine();
//                        if (in.compareTo("o") == 0) {
//                            preform("o");
//                            file2 = num_files - 1;
//                            JOptionPane.showMessageDialog(null,"Would you like to merge the following files? (y/n)");
//                            print_file_name(file1);
//                            print_file_name(file2);
//                            if (input.readLine().compareTo("y") != 0) {
//                                return 0;
//                            }
//                        }
//                    } while (!is_int(in));
//                    file2 = Integer.parseInt(in);
//                }
//                if (format) {
//                    format_file(file1, true);
//                    format_file(file2, true);
//                    merge_files(num_files - 2, num_files - 1);
//                } else {
//                    merge_files(file1, file2);
//                }
//                return 0;
//            }
////            if (command.charAt(0) == 'p') {
////                String line = command.substring(1).replaceAll(" ", "");
////
////                if (is_int(line)) {
////                    format_file(Integer.parseInt(line) - 1, true);
////                } else {
////                    // get file number and format
////                }
////
////                return 0;
////            }
//            if (command.charAt(0) == 'f') {
//                print_file_list();
//                return 0;
//            }
//            if (command.charAt(0) == 'c') {
//                return -1;
//            }
//            JOptionPane.showMessageDialog(null,"\"" + command + "\" is not a valid command. Type h for help.");
//        }
////	catch (Exception e)
//        {
////		JOptionPane.showMessageDialog(null,"There was an error:\n"+e);
//        }
//        return 0;
//    }
    static void help_menu() {
        JOptionPane.showMessageDialog(null, "c - close program");
        JOptionPane.showMessageDialog(null, "cf - Compile Finaces ");
        JOptionPane.showMessageDialog(null, "d - find duplicates in a singe file e.g. \"d 2\"");
        JOptionPane.showMessageDialog(null, "f - show list of all loaded files");
        JOptionPane.showMessageDialog(null, "h - help menu");
        JOptionPane.showMessageDialog(null, "m - merge files e.g. \"m 1,2\" would merge files 1 and 2");
        JOptionPane.showMessageDialog(null, "pm - format and then merge files e.g. \"m 1,2\" would merge files 1 and 2");
        JOptionPane.showMessageDialog(null, "o - open and load a new file");
        JOptionPane.showMessageDialog(null, "p - make a file proper e.g. \"p 3\"");
    }
}
